local bazheng = fk.CreateSkill{
    name = "ym1__bazheng",
    tags = {Skill.Compulsory},
    --attached_skill_name = "ym1__quanji",
}
Fk:loadTranslationTable{
    ["ym1__bazheng"] = "霸政",
    [":ym1__bazheng"] = "锁定技，所有角色均拥有“权计”，且其他角色的“权”于你回合内视为“<a href='ym1__shencaizhang'>杖</a>”，于其回合结束时视为“<a href='ym1__shencaisi'>死</a>”。",
    ["ym1__shencaizhang"] = "无法响应【杀】",
    ["ym1__shencaisi"] = "回合结束时，若你“死”标记个数大于场上存活人数，你死亡。",

    ["$ym1__bazheng1"] = "吾令既出，安敢不从？",
    ["$ym1__bazheng2"] = "汝行此举，是要谋反吗？",
}
bazheng:addEffect(fk.TargetSpecified,{
    anim_type = "offensive",
    can_trigger = function (self, event, target, player, data)
        if player:hasSkill(bazheng.name) then
            return player.phase ~= Player.NotActive and data.to ~= player and data.card.trueName == "slash" and #data.to:getPile("ym1__zhonghui_power") > 0
        end
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        local room = player.room
        data.disresponsive = true
    end,
})
bazheng:addEffect(fk.TurnEnd,{
    anim_type = "offensive",
    can_trigger = function (self, event, target, player, data)
        if player:hasSkill(bazheng.name) then
            return player ~= target and #target:getPile("ym1__zhonghui_power") > #player.room.alive_players
        end
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:killPlayer({who = target})
    end,
})
bazheng:addEffect(fk.Deathed,{
    can_refresh = function (self, event, target, player, data)
        return target == player and #table.filter(Fk:currentRoom().alive_players, function(p) return p:hasSkill(bazheng.name) and p ~= player end) == 0
    end,
    on_refresh = function (self, event, target, player, data)
        local room = player.room
        for _, p in ipairs(room.alive_players) do
            local quan = p:getPile("ym1__zhonghui_power")
            if #quan > 0 then
                room:throwCard(quan, bazheng.name, p, p)
            end
        end
    end,
})
bazheng:addEffect(fk.EventLoseSkill,{
    can_refresh = function (self, event, target, player, data)
        return player:hasSkill(bazheng.name) and data.skill.name == "ym1__quanji" and not data.who.dead
    end,
    on_refresh = function (self, event, target, player, data)
        if not data.who:hasSkill("ym1__quanji") then
            player.room:setPlayerMark(data.who,"ym1__bazheng_quanji",1)
            player.room:handleAddLoseSkills(data.who,"ym1__quanji&",nil,false,true)
        end
    end,
})
bazheng:addAcquireEffect(function (self, player, is_start)
    if not player:hasSkill("ym1__quanji") then
        player.room:setPlayerMark(player,"ym1__bazheng_quanji",1)
        player.room:handleAddLoseSkills(player,"ym1__quanji&",nil,false,true)
    end
end)
bazheng:addLoseEffect(function (self, player, is_death)
    if player:getMark("ym1__bazheng_quanji") ~= 0 then
        player.room:setPlayerMark(player,"ym1__bazheng_quanji",0)
        player.room:handleAddLoseSkills(player,"-ym1__quanji&",nil,false,true)
    end
end)
return bazheng